package models.pubobj;

import models.*;
import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;

import com.avaje.ebean.validation.NotNull;

import java.util.List;

/**
 * User: yeqingzhou
 * Date: 12-8-30
 */
@Entity
public class AniObjectState extends Model {
	
	@Id
    public Long id;
    
	@NotNull
    public String stateKey;

    public AniObjectState(String stateKey) {
        this.stateKey = stateKey;
    }

    public AniObjectState(Long id) {
        this.id = id;
    }

    public AniObjectState(Long id, String stateKey) {
		super();
		this.id = id;
		this.stateKey = stateKey;
	}

	// -- Queries

    public static Model.Finder<Long, AniObjectState> find = new Model.Finder<Long, AniObjectState>(Long.class, AniObjectState.class);

    public static List<AniObjectState> findAll() {
        return find.all();
    }

    public static AniObjectState findByStateKey(String stateKey) {
    	
        return find.where().eq("stateKey", stateKey).findUnique();
    }

    public static AniObjectState findById(Long stateId){
        return find.where().idEq(stateId).findUnique();
    }
    
    public enum States{
    	ACTIVATED,
    	APPROVAL_IN_PROGRESS,
    	DISABLED,
    	RETIRED
    }

}
